package top.aylan.org.service.impl;

import org.springframework.stereotype.Service;
import top.aylan.org.dao.OptionsMapper;
import top.aylan.org.entity.Options;
import top.aylan.org.entity.OptionsExample;
import top.aylan.org.service.OptionsService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2018/12/22.
 */
@Service
public class OptionsServiceImpl implements OptionsService {

    @Resource
    OptionsMapper optionsMapper;

    @Override
    public void save(Options options) throws Exception {
        optionsMapper.insert(options);
    }

    @Override
    public List<Options> findAllOptions() throws Exception {
        OptionsExample optionsExample = new OptionsExample();
        return  optionsMapper.selectByExample(optionsExample);
    }

    @Override
    public Options findOptionsById(byte id) throws Exception {
        return optionsMapper.selectByPrimaryKey(id);
    }

    @Override
    public Options findOptionsByKeyName(String keyName) throws Exception {
        OptionsExample example = new OptionsExample();
        OptionsExample.Criteria criteria = example.createCriteria();
        criteria.andOptionNameEqualTo(keyName);
        optionsMapper.selectByExample(example);
        return null;
    }

    @Override
    public int update(Options options) {
       return optionsMapper.updateByPrimaryKey(options);
    }
}
